package day05_api.com.itheima.d3_method_reference;

import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        // 目标：理解静态方法引用。
        Student[] students = new Student[4]; // students = [null, null, null, null]
        students[0] = new Student("周芷若", 21, '女', 169.3);
        students[1] = new Student("殷素素", 38, '女', 172.2);
        students[2] = new Student("小昭", 19, '女', 168.5);
        students[3] = new Student("张无忌", 23, '男', 183.5);

        Arrays.sort(students, (o1, o2) -> Double.compare(o1.getHeight(), o2.getHeight()));

        Test2 t = new Test2();
        Arrays.sort(students,(o1, o2) -> t.compareByHeight(o1, o2));

        Arrays.sort(students, t::compareByHeight);

        Arrays.sort(students, new Test2()::compareByHeight);



    }
    public int compareByHeight(Student o1, Student o2) {
        return Double.compare(o1.getHeight(), o2.getHeight());
    }
}
